package com.song.provider.controller;

import com.song.provider.pojo.Book;
import com.song.provider.service.BookService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 宋伟宁
 * @Date 2024/1/9
 * @Version 1.0
 **/
@RestController
public class BookController {

    @Resource
    private BookService bookService;
    @Value("${server.port}")
    private String port;


    @GetMapping("/msg")
    public String message(){
        return "访问了stock服务"+this.port;
    }

    @GetMapping("/")
    public List<Book> getBookList(){
        return bookService.books();
    }

    @PutMapping("/stock")
    public Boolean stock(@RequestParam("id") Long id,@RequestParam("count")Long count){
         return  this.bookService.stock(id,count);
    }


}
